/**
 * 
 */
package datatype;

/**
 * @author Artur Tolstenco
 *
 */

/**
 * Class that implements the Arc (Edge)
 */
public class Edge {
	private final Vertex target;
	private final double weight;
	
	public Edge(Vertex target, double weight) {
		this.target = target;
		this.weight = weight;
	}
	

	/**
	 * @return the target
	 */
	public Vertex getTarget() {
		return target;
	}

	/**
	 * @return the weight
	 */
	public double getWeight() {
		return weight;
	}


	@Override
	public String toString() {
		return target + " -> " + weight;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((target == null) ? 0 : target.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Edge other = (Edge) obj;
		if (target == null) {
			if (other.target != null)
				return false;
		} else if (!target.equals(other.target))
			return false;
		return true;
	}
	
}
